package com.beauty.dressing.common.utils;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

import java.io.ByteArrayOutputStream;

public class ImageBase64 {
    /**
     * base64压缩
     *
     * @param picUrl
     * @return
     */
    public static String getImageToBase64(String picUrl) {
        String picBase64;
        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inSampleSize = 1;
        Bitmap bitmapOrg = BitmapFactory.decodeFile(picUrl, opts);
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 30, bao);
        byte[] ba = bao.toByteArray();
        picBase64 = Base64.encodeToString(ba, Base64.NO_WRAP);
        return picBase64;
    }
}
